package br.ufc.quixada.adrs.dao;

import java.sql.SQLException;

import br.ufc.quixada.adrs.dao.config.PostGresMapConfig;
import br.ufc.quixada.adrs.model.Papel;
import br.ufc.quixada.adrs.util.Msg;
import org.slf4j.LoggerFactory;

public class PapelDAO {

    public Papel getById(Long id) {
        Papel papel = null;
        try {
            papel = (Papel) PostGresMapConfig.getSqlMapClient().queryForObject("getPapelById", id);
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
        return papel;
    }

    public Papel getByNome(String nome) {
        Papel papel = null;
        try {
            papel = (Papel) PostGresMapConfig.getSqlMapClient().queryForObject("getPapelByNome", nome);
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
        return papel;
    }
}
